/*
 * @Descripttion: 出手鸭小程序
 * @version:1.0.1 
 * @Author: HHL
 * @Date: 2023-10-16 11:26:08
 * @LastEditTime: 2023-10-16 11:26:08
 * @LastEditors:Hui
 */

import qs from 'qs'


// 内页跳转
export const goPage = (page = 'home', params = {}) => {
  let url = '' // h5 页面链接
  let appUrl = '' // app 页面连接

  switch (page) {
    // 分类页面
    case 'category':
      url = '/pages/category/index'
      appUrl = '/category'
      break;
    // 产品页面
    case 'product':
      url = '/pages/product/index'
      appUrl = '/product'
      break;
    // 券包页面
    case 'coupon':
      url = '/pages/coupon/index'
      appUrl = '/coupon'
      break;
    default:
      url = '/pages/index/index'
      appUrl = '/'
  }

  const platform = uni.getStorageSync('platform')
  if (platform === 'app') {
    const obj = Object();
    obj.url = appUrl;
    obj.data = params;
    const json = JSON.stringify(obj);
    // @ts-ignore
    share.postMessage(json);
    return
  }

  uni.navigateTo({ url: `${url}?${qs.stringify(params)}` })
}